//
//  SecViewController.m
//  07- 界面传值block delegate
//
//  Created by mafeng on 16/7/22.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "SecViewController.h"
#import "FirstViewController.h"

@interface SecViewController ()
@property (nonatomic, strong) UITextField *textField;
@end

@implementation SecViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
    self.textField.backgroundColor = [UIColor blueColor];
    self.textField.text = self.titleString;
    [self.view addSubview:self.textField];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor yellowColor];
    button.frame = CGRectMake(20, 100, 100, 50);
    [button setTitle:@"上一页" forState:UIControlStateNormal];
     [button addTarget:self action:@selector(pop) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}
- (void)pop {
    NSInteger count = self.navigationController.viewControllers.count;
    FirstViewController *first = self.navigationController.viewControllers[count - 2];
    NSLog(@"%@", self.navigationController.viewControllers);
    first.titleTextFiled = self.textField.text;
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
